import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JList;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.awt.ScrollPane;


public class Stundenanzeigen extends JPanel {
	private JTable table;

	/**
	 * Create the panel.
	 * @throws SQLException 
	 */
	public Stundenanzeigen() throws SQLException {
		setLayout(null);
		
		
		
		
		JLabel lblStundenAnzeigen = new JLabel("Stunden Anzeigen");
		lblStundenAnzeigen.setBounds(167, 6, 138, 16);
		add(lblStundenAnzeigen);
		
		JButton btnZurck = new JButton("Zur\u00FCck");
		btnZurck.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Stundenrechner.getStart().setContentPane(new Stundenrechner().getContentPane());
				Stundenrechner.getStart().validate();				
			}
		});
		btnZurck.setBounds(19, 245, 117, 29);
		add(btnZurck);
		final DefaultTableModel StundenModel = new DefaultTableModel();
		
		final JScrollPane scrollPane = new JScrollPane(table);
		scrollPane.setBounds(75, 51, 299, 168);
		add(scrollPane);
		
		JButton btnAnzeigen = new JButton("Anzeigen");
		btnAnzeigen.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			try {
				table.setVisible(true);
				table.repaint();
				table.validate();
				table.setModel(Connector.ausgabefensterSQL(StundenModel));
				table.setVisible(true);
				table.repaint();
				table.validate();
				add(table);		
				scrollPane.add(table);
				table.setVisible(true);
				table.repaint();
				table.validate();
			} catch (SQLException e) {
				// TODO Automatisch generierter Erfassungsblock
				e.printStackTrace();
			}
			
				
			}
		});
		btnAnzeigen.setBounds(277, 245, 117, 29);
		add(btnAnzeigen);
		
		table = new JTable();
		table.setBounds(381, 84, 63, 42);
		add(table);
		
		
		


	}
}
